home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
ftp.cs.arizona.edu
/
ftp.cs.arizona.edu.tar
/
ftp.cs.arizona.edu
/
icon
/
newsgrp
/
group92c.txt
/
000034_icon-group-sender _Tue Oct 20 03:29:23 1992.msg
< prev
next >
Wrap
Internet Message Format
|
1993-01-04
|
2KB
Received: by cheltenham.cs.arizona.edu; Sat, 24 Oct 1992 08:22:03 MST
Date: 20 Oct 92 03:29:23 GMT
From: uchinews!ellis!goer@speedy.wisc.edu (Richard L. Goerwitz)
Organization: University of Chicago Computing Organizations
Subject: Re: How to skip comments?
Message-Id: <1992Oct20.032923.20595@midway.uchicago.edu>
References: <199210131550.AA16871@optima.cs.arizona.edu>
Sender: icon-group-request@cs.arizona.edu
To: icon-group@cs.arizona.edu
Status: R
Errors-To: icon-group-errors@cs.arizona.edu
In article <199210131550.AA16871@optima.cs.arizona.edu> UBY@CU.NIH.GOV writes:
>I have been trying to modify the concord.icn program from the Icon program
>library to produce cross-reference tables for SAS programs, but I am stumped
>about how to skip over comments. Comments in the SAS language are of the form
>/* ..... */.
What you want to do is perhaps to create a little machine with four states,
and use it in place of read(). I don't know what sort of machine you are
using, but assuming that lines terminate with \n, you might write something
like what I have below. Note that I haven't coded the routine to collect
the text into lines. It just suspends characters that don't constitute
part of the comments:
procedure stripped_sas()
local c, state
state := 0
every c := !(!&input || "\n") do {
case state of {
0 : {
if c == "/"
then state := 1
else suspend c
}
1 : {
if c == "*"
then state := 2
else {
suspend "/" | c
state := 0
}
}
2 : {
if c == "*"
then state := 3
}
3 : {
if c == "/"
then state := 0
else state := 2
}
}
}
end
--
-Richard L. Goerwitz goer%midway@uchicago.bitnet
goer@midway.uchicago.edu rutgers!oddjob!ellis!goer